<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: drogon::PubSubService&lt; MessageType &gt; 模板类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.8 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">载入中...</div>
<div class="SRStatus" id="Searching">搜索中...</div>
<div class="SRStatus" id="NoMatches">未找到</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespacedrogon.html">drogon</a></li><li class="navelem"><a class="el" href="classdrogon_1_1PubSubService.html">PubSubService</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public 类型</a> &#124;
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="classdrogon_1_1PubSubService-members.html">所有成员列表</a>  </div>
  <div class="headertitle"><div class="title">drogon::PubSubService&lt; MessageType &gt; 模板类 参考</div></div>
</div><!--header-->
<div class="contents">

<p>This class template implements a publish-subscribe pattern with multiple named topics.  
 <a href="classdrogon_1_1PubSubService.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="PubSubService_8h_source.html">PubSubService.h</a>&gt;</code></p>
<div class="dynheader">
类 drogon::PubSubService&lt; MessageType &gt; 继承关系图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1PubSubService__inherit__graph.png" border="0" usemap="#adrogon_1_1PubSubService_3_01MessageType_01_4_inherit__map" alt="Inheritance graph"/></div>
<map name="adrogon_1_1PubSubService_3_01MessageType_01_4_inherit__map" id="adrogon_1_1PubSubService_3_01MessageType_01_4_inherit__map">
<area shape="rect" title="This class template implements a publish&#45;subscribe pattern with multiple named topics." alt="" coords="5,79,176,119"/>
<area shape="rect" title=" " alt="" coords="10,5,171,31"/>
<area shape="poly" title=" " alt="" coords="93,44,93,79,88,79,88,44"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<div class="dynheader">
drogon::PubSubService&lt; MessageType &gt; 的协作图:</div>
<div class="dyncontent">
<div class="center"><img src="classdrogon_1_1PubSubService__coll__graph.png" border="0" usemap="#adrogon_1_1PubSubService_3_01MessageType_01_4_coll__map" alt="Collaboration graph"/></div>
<map name="adrogon_1_1PubSubService_3_01MessageType_01_4_coll__map" id="adrogon_1_1PubSubService_3_01MessageType_01_4_coll__map">
<area shape="rect" title="This class template implements a publish&#45;subscribe pattern with multiple named topics." alt="" coords="5,79,176,119"/>
<area shape="rect" title=" " alt="" coords="10,5,171,31"/>
<area shape="poly" title=" " alt="" coords="93,44,93,79,88,79,88,44"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">图例</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-types" name="pub-types"></a>
Public 类型</h2></td></tr>
<tr class="memitem:aef09df9e6709fdde595323fb86fc8c9e" id="r_aef09df9e6709fdde595323fb86fc8c9e"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> = std::function&lt; void(const std::string &amp;, const MessageType &amp;)&gt;</td></tr>
<tr class="separator:aef09df9e6709fdde595323fb86fc8c9e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2c701a64f6958bfd4d33fbbb83a944c0" id="r_a2c701a64f6958bfd4d33fbbb83a944c0"><td class="memItemLeft" align="right" valign="top">using&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a2c701a64f6958bfd4d33fbbb83a944c0">SharedMutex</a> = std::shared_timed_mutex</td></tr>
<tr class="separator:a2c701a64f6958bfd4d33fbbb83a944c0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a4eb1570db8e7cd3b52c0a9d6a1aaab7f" id="r_a4eb1570db8e7cd3b52c0a9d6a1aaab7f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a4eb1570db8e7cd3b52c0a9d6a1aaab7f">publish</a> (const std::string &amp;topicName, const MessageType &amp;message) const</td></tr>
<tr class="memdesc:a4eb1570db8e7cd3b52c0a9d6a1aaab7f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Publish a message to a topic. The message will be broadcasted to every subscriber.  <br /></td></tr>
<tr class="separator:a4eb1570db8e7cd3b52c0a9d6a1aaab7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7cf825d629c9bd39b8c48d038511bb69" id="r_a7cf825d629c9bd39b8c48d038511bb69"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a7cf825d629c9bd39b8c48d038511bb69">subscribe</a> (const std::string &amp;topicName, const <a class="el" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;handler)</td></tr>
<tr class="memdesc:a7cf825d629c9bd39b8c48d038511bb69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the topic and message as parameters.  <br /></td></tr>
<tr class="separator:a7cf825d629c9bd39b8c48d038511bb69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3f36abdc474cfbac205bf9a0ea63d064" id="r_a3f36abdc474cfbac205bf9a0ea63d064"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a3f36abdc474cfbac205bf9a0ea63d064">subscribe</a> (const std::string &amp;topicName, <a class="el" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;&amp;handler)</td></tr>
<tr class="memdesc:a3f36abdc474cfbac205bf9a0ea63d064"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the topic and message as parameters.  <br /></td></tr>
<tr class="separator:a3f36abdc474cfbac205bf9a0ea63d064"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4e93f776603051dbd3f2da52ec34395" id="r_aa4e93f776603051dbd3f2da52ec34395"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#aa4e93f776603051dbd3f2da52ec34395">unsubscribe</a> (const std::string &amp;topicName, <a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> id)</td></tr>
<tr class="memdesc:aa4e93f776603051dbd3f2da52ec34395"><td class="mdescLeft">&#160;</td><td class="mdescRight">Unsubscribe from a topic.  <br /></td></tr>
<tr class="separator:aa4e93f776603051dbd3f2da52ec34395"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad0db22a9172a36b5358284c570dcb7ae" id="r_ad0db22a9172a36b5358284c570dcb7ae"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#ad0db22a9172a36b5358284c570dcb7ae">size</a> () const</td></tr>
<tr class="memdesc:ad0db22a9172a36b5358284c570dcb7ae"><td class="mdescLeft">&#160;</td><td class="mdescRight">return the number of topics.  <br /></td></tr>
<tr class="separator:ad0db22a9172a36b5358284c570dcb7ae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a49beac8cd7262016b452049851fba22a" id="r_a49beac8cd7262016b452049851fba22a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a49beac8cd7262016b452049851fba22a">clear</a> ()</td></tr>
<tr class="memdesc:a49beac8cd7262016b452049851fba22a"><td class="mdescLeft">&#160;</td><td class="mdescRight">remove all topics.  <br /></td></tr>
<tr class="separator:a49beac8cd7262016b452049851fba22a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adf4f371214a0ceaff8d4e9211363ccf5" id="r_adf4f371214a0ceaff8d4e9211363ccf5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#adf4f371214a0ceaff8d4e9211363ccf5">removeTopic</a> (const std::string &amp;topicName)</td></tr>
<tr class="memdesc:adf4f371214a0ceaff8d4e9211363ccf5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove a topic  <br /></td></tr>
<tr class="separator:adf4f371214a0ceaff8d4e9211363ccf5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20c777adfb76690d9c1c53ac27eabff1" id="r_a20c777adfb76690d9c1c53ac27eabff1"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classdrogon_1_1PubSubService.html#a20c777adfb76690d9c1c53ac27eabff1">isTopicEmpty</a> (const std::string &amp;topicName) const</td></tr>
<tr class="memdesc:a20c777adfb76690d9c1c53ac27eabff1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Check if a topic is empty.  <br /></td></tr>
<tr class="separator:a20c777adfb76690d9c1c53ac27eabff1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><div class="compoundTemplParams">template&lt;typename MessageType&gt;<br />
class drogon::PubSubService&lt; MessageType &gt;</div><p>This class template implements a publish-subscribe pattern with multiple named topics. </p>
<dl class="tparams"><dt>模板参数</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">MessageType</td><td>The message type. </td></tr>
  </table>
  </dd>
</dl>
</div><h2 class="groupheader">成员类型定义说明</h2>
<a id="aef09df9e6709fdde595323fb86fc8c9e" name="aef09df9e6709fdde595323fb86fc8c9e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aef09df9e6709fdde595323fb86fc8c9e">&#9670;&#160;</a></span>MessageHandler</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::MessageHandler =  std::function&lt;void(const std::string &amp;, const MessageType &amp;)&gt;</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="a2c701a64f6958bfd4d33fbbb83a944c0" name="a2c701a64f6958bfd4d33fbbb83a944c0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c701a64f6958bfd4d33fbbb83a944c0">&#9670;&#160;</a></span>SharedMutex</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">using <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::SharedMutex =  std::shared_timed_mutex</td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<h2 class="groupheader">成员函数说明</h2>
<a id="a49beac8cd7262016b452049851fba22a" name="a49beac8cd7262016b452049851fba22a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a49beac8cd7262016b452049851fba22a">&#9670;&#160;</a></span>clear()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::clear </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>remove all topics. </p>

</div>
</div>
<a id="a20c777adfb76690d9c1c53ac27eabff1" name="a20c777adfb76690d9c1c53ac27eabff1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a20c777adfb76690d9c1c53ac27eabff1">&#9670;&#160;</a></span>isTopicEmpty()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::isTopicEmpty </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Check if a topic is empty. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">topicName</td><td>The topic name. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>true means there are no subscribers. </dd>
<dd>
false means there are subscribers in the topic. </dd></dl>

</div>
</div>
<a id="a4eb1570db8e7cd3b52c0a9d6a1aaab7f" name="a4eb1570db8e7cd3b52c0a9d6a1aaab7f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4eb1570db8e7cd3b52c0a9d6a1aaab7f">&#9670;&#160;</a></span>publish()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::publish </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const MessageType &amp;&#160;</td>
          <td class="paramname"><em>message</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Publish a message to a topic. The message will be broadcasted to every subscriber. </p>

</div>
</div>
<a id="adf4f371214a0ceaff8d4e9211363ccf5" name="adf4f371214a0ceaff8d4e9211363ccf5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adf4f371214a0ceaff8d4e9211363ccf5">&#9670;&#160;</a></span>removeTopic()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::removeTopic </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Remove a topic </p>

</div>
</div>
<a id="ad0db22a9172a36b5358284c570dcb7ae" name="ad0db22a9172a36b5358284c570dcb7ae"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad0db22a9172a36b5358284c570dcb7ae">&#9670;&#160;</a></span>size()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">size_t <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::size </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>return the number of topics. </p>

</div>
</div>
<a id="a7cf825d629c9bd39b8c48d038511bb69" name="a7cf825d629c9bd39b8c48d038511bb69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7cf825d629c9bd39b8c48d038511bb69">&#9670;&#160;</a></span>subscribe() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::subscribe </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;&#160;</td>
          <td class="paramname"><em>handler</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the topic and message as parameters. </p>

</div>
</div>
<a id="a3f36abdc474cfbac205bf9a0ea63d064" name="a3f36abdc474cfbac205bf9a0ea63d064"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3f36abdc474cfbac205bf9a0ea63d064">&#9670;&#160;</a></span>subscribe() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a> <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::subscribe </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classdrogon_1_1PubSubService.html#aef09df9e6709fdde595323fb86fc8c9e">MessageHandler</a> &amp;&amp;&#160;</td>
          <td class="paramname"><em>handler</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Subscribe to a topic. When a message is published to the topic, the handler is invoked by passing the topic and message as parameters. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">topicName</td><td><a class="el" href="classdrogon_1_1Topic.html" title="This class template presents an unnamed topic.">Topic</a> name. </td></tr>
    <tr><td class="paramname">handler</td><td>The message handler. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>返回</dt><dd>The subscriber ID. </dd></dl>

</div>
</div>
<a id="aa4e93f776603051dbd3f2da52ec34395" name="aa4e93f776603051dbd3f2da52ec34395"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa4e93f776603051dbd3f2da52ec34395">&#9670;&#160;</a></span>unsubscribe()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename MessageType &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classdrogon_1_1PubSubService.html">drogon::PubSubService</a>&lt; MessageType &gt;::unsubscribe </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>topicName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacedrogon.html#a7f1da84a8169f7a3aefb1403cc16bae9">SubscriberID</a>&#160;</td>
          <td class="paramname"><em>id</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Unsubscribe from a topic. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">topicName</td><td><a class="el" href="classdrogon_1_1Topic.html" title="This class template presents an unnamed topic.">Topic</a> name. </td></tr>
    <tr><td class="paramname">id</td><td>The subscriber ID returned from the subscribe method. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li><a class="el" href="PubSubService_8h_source.html">PubSubService.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8
</small></address>
</body>
</html>
